package homework0707;

import jk.ToolService;

public class StringObj implements ToolService {
    @Override
    public String timeUtil(DateElement dateelement) {
        return null;
    }

    @Override
    public String transformUtil(StringElement stringElement) {
        int type = stringElement.getType();
        String str = stringElement.getStr();
        if (type == 0) {//就是驼峰转蛇型
            str = str.replaceAll("[A-Z]", "_$0");
            str = str.toLowerCase();
            if (str.charAt(0) == '_') {
                str = str.substring(1);
                return str;
            }
        } else if (type == 1) {
            str = str.replaceAll("_([A-Z])", "$1");
            int i = -32;
            for (char c = 'a'; c <= 'z'; ++c) {
                str = str.replaceAll("_" + c, String.valueOf((char) (c + i)));
            }
            return str;
        }
        return "类型有误";
    }

    @Override
    public String transformUtil1(double number) {
        return null;
    }

}